import pytest
from loguru import logger

from basic.base_driver import DRIVER
from page.page_main import PageMain

MAIN = PageMain()


def app():
    if DRIVER.is_app_installed("com.xiaomi.shop") is False:
        logger.info("未安装小米商城，开始安装")
        DRIVER.install_app("app/xiaomi_shop.apk")
    yield
    logger.info("移除小米商城")
    #DRIVER.remove_app()


@pytest.fixture(scope="function",autouse=True)
def start_case():
    logger.info(f"{'=' * 20} 开始执行case {'=' * 20}")
    DRIVER.activate_app("com.xiaomi.shop")

    yield
    logger.info(f"{'=' * 20} 执行case结束 {'=' * 20}")
    DRIVER.terminate_app("com.xiaomi.shop")

